package com.fushihua.y2015.m07.d19;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class GetMD5 {
    public static String getMD5(String instr){
        MessageDigest md5=null;
        StringBuilder sb=new StringBuilder(32);
        try {
            md5=MessageDigest.getInstance("MD5");
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
            return null;
        }
        byte[] outbt=md5.digest(instr.getBytes());
        for(int i=0;i<outbt.length;i++){
            int c=outbt[i]&0xff;
            if(c<16)sb.append(0);
            sb.append(Integer.toHexString(c));
        }
        return sb.toString();
    }
    
    public static void main(String[] args) {
		System.out.println(getMD5("111111aa"));
	}
}
